subroutine calcene3(iin1, iin2, leth, eccsd, fact)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
implicit none
integer, intent(in) :: leth
real*8, intent(inout) :: eccsd
real*8, intent(in) :: iin1(*), iin2(*), fact
!
if(prec==8.and.igpu==0) then 
   call calcene3_d(iin1, iin2, leth, eccsd, fact)
elseif(prec==4.and.igpu==0) then 
   call calcene3_s(iin1, iin2, leth, eccsd, fact)
elseif(prec==8.and.igpu==1) then 
   call calcene3_dg(iin1, iin2, leth, eccsd, fact)
elseif(prec==4.and.igpu==1) then 
   call calcene3_sg(iin1, iin2, leth, eccsd, fact)
endif
!
return
end

subroutine calcene3_d(iin1, iin2, leth, eccsd, fact)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
!use common
implicit none
integer, intent(in) :: leth
real*8, intent(inout) :: eccsd
real*8, intent(in) :: iin1(*), iin2(*), fact
!
real*8, external :: ddot
integer :: i
!
!$omp parallel do reduction(+:eccsd)
do i = 1, leth
   eccsd = eccsd + fact*iin1(i)*iin2(i)
enddo
!$omp end parallel do
!
return
end
!
subroutine calcene3_s(iin1, iin2, leth, eccsd, fact)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
!use common
implicit none
integer, intent(in) :: leth
real*8, intent(inout) :: eccsd, fact
real*4, intent(in) :: iin1(*), iin2(*)
!
real*8 :: eso
real*4, external :: sdot
integer i
!
!$omp parallel do reduction(+:eccsd)
do i = 1, leth
   eccsd = eccsd + fact*iin1(i)*iin2(i)
enddo
!$omp end parallel do
!
return
end
!
subroutine calcene3_dg(iin1, iin2, leth, eccsd, fact)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
!use common
implicit none
integer, intent(in) :: leth
real*8, intent(inout) :: eccsd, fact
real*8, intent(in),device :: iin1(*), iin2(*)
!
real*8 :: eso
integer i
!
!$acc parallel loop reduction(+:eccsd)
do i = 1, leth
   eccsd = eccsd + fact*iin1(i)*iin2(i)
enddo
!$acc end parallel loop
!
return
end
!
subroutine calcene3_sg(iin1, iin2, leth, eccsd, fact)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
!use common
implicit none
integer, intent(in) :: leth
real*8, intent(inout) :: eccsd, fact
real*4, intent(in),device :: iin1(*), iin2(*)
!
real*8 :: eso
real*4, external :: sdot
integer i
!
!$acc parallel loop reduction(+:eccsd)
do i = 1, leth
   eccsd = eccsd + fact*iin1(i)*iin2(i) 
enddo
!$acc end parallel loop
!
return
end
